<!DOCTYPE html>
<!--
  ~ Copyright (C) 2018 guomw.Inc. All rights reserved.
  ~ 项目名称： mysite
  ~ 文件名称： list.html
  ~ Date：18-10-15 下午3:33
  ~ Author: guomw
  -->

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/head::head('数据上链')">
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <!--search-->
    <form role="form" class="search-panel">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content p-m no-borders">
                        <!--<div class="form-inline font-bold">-->
                        <!--报告数据-->
                        <!--</div>-->

                        <!--<p style="height: 8px;"></p>-->
                        <!--<div class="form-inline">-->
                        <!--<label class="control-label">报告模板：</label>-->
                        <!--<select><option value="乳腺癌外泌体检测报告">乳腺癌外泌体检测报告</option></select>-->
                        <!--</div>-->

                        <!--<p style="height: 8px;"></p>-->
                        <!--<div class="form-inline">-->
                        <!--<label class="control-label">上链文件：</label>-->
                        <!--<div style="margin-left: 10px; line-height: 150px;">-->
                        <!--<a id="uploadpic1" class="btn-lit jUploader-button" href="#"-->
                        <!--style="cursor: pointer; position: relative; overflow: hidden; direction: ltr;">-->
                        <!--<span style="color: #c1b3a9">-->
                        <!--上传上链文件-->
                        <!--</span>-->
                        <!--<input type="file" onchange="uploadImage(1)"-->
                        <!--name="shareImage" id="shareImage1"-->
                        <!--style="position: absolute; right: 0px; top: -70px; margin: 0px; opacity: 0; padding: 0px; font-family: Arial; font-size: 118px; vertical-align: baseline; cursor: pointer;"/>-->
                        <!--</a>-->
                        <!--<input type="hidden" id="reportUrl"/>-->
                        <!--<span id="fileStatus" style="color:blue"></span>-->
                        <!--</div>-->


                        <!--</div>-->
                        <div class="form-inline font-bold">
                            上链文件
                        </div>
                        <p style="height: 8px;"></p>
                        <div id="list" style="margin-left: 24px;">
                            检测文件搜索中...
                        </div>
                        <input type="hidden" id="files"/>
                        <p style="height: 8px;"></p>
                        <div class="form-inline font-bold">
                            补充信息
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">最原始文件Code：</label>
                            <input type="text" class="form-control input-sm mb10" id="GCode" name="GCode"/>
                        </div>

                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">初步处理的文件Code：</label>
                            <input type="text" class="form-control input-sm mb10" id="MCode" name="MCode"/>
                        </div>
                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">关键字：</label>
                            <input type="text" class="form-control input-sm mb10" id="keywords" name="keywords"/>
                        </div>
                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <label class="control-label">手机号：</label>
                            <input type="text" class="form-control input-sm mb10 fa-mobile" id="mobile" name="mobile"
                            />
                        </div>
                        <p style="height: 8px;"></p>
                        <div class="form-inline">
                            <button type="button" class="btn btn-success" onclick="uploadChain()">上传数据</button>
                            <input type="hidden" id="code" name="code" th:value="${code}"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

</div>

<footer th:include="/common/footer::js"/>
<!--<script type="text/javascript" src="../../resource/js/ajaxfileupload.js"-->
<!--th:src="@{/resource/js/ajaxfileupload.js}"></script>-->
<script>
    // function uploadImage(id) {
    //     $.ajaxFileUpload({
    //         url: '/user/uploadReportFile',
    //         secureuri: false,
    //         fileElementId: 'shareImage' + id,
    //         dataType: 'json',
    //         data: null,
    //         success: function (data) {
    //             if (data.resultCode == 1) {
    //                 swal("上传文件成功", "", "success");
    //
    //                 $("#reportUrl").val(data.data);
    //                 $("#fileStatus").html("报告文件已上传");
    //             }
    //         },
    //         error: function (data, status, e) {
    //             swal("上传失败，请检查网络后重试" + e, "", "warning")
    //         }
    //     });
    // }


    $(function () {


        var params = {
            code: $("#code").val()
        };
        hotUtil.loading.show();
        hotUtil.ajaxCall("/user/findChainFiles", params, function (ret) {
            hotUtil.loading.close();
            if (ret.resultCode == 1) {
                var html = "";
                var data = ret.data;
                var files = "";

                for (var i = 0; i < data.length; i++) {
                    html += "<div>" + data[i] + "</div>";
                    files += data[i] + ',';
                }
                $("#files").val(files);
                if (data.length > 0) {
                    $("#list").html('<div>搜索到下列的上链文件：</div>' + html);
                } else {
                    $("#list").html("没有找到上链文件");
                }
                // swal("搜索完成", "", "success");
            } else {
                swal("搜索失败", "", "warning")
            }
        });
    });

    function uploadChain() {

        var files = $("#files").val();
        if (files == "") {
            swal("没有找到上链文件，请上传文件", "", "warning")
            return;
        }

        files = files.replace(",", "");

        var params = {
            code: $("#code").val(),
            files: files,
            keywords: $("#keywords").val(),
            mobile: $("#mobile").val(),
            GCode: $("#GCode").val(),
            MCode: $("#MCode").val()
        };

        hotUtil.loading.show();
        hotUtil.ajaxCall("/user/saveChain", params, function (ret) {
            hotUtil.loading.close();
            if (ret.resultCode == 1) {
                swal("上链成功", "", "success");
                window.location.href = "/user/list";
            } else {
                swal("上链失败，请检查网络后重试", "", "warning")
            }
        });
    }
</script>
</body>
</html>
